package org.squarecap.apps.eventcompanion.domain;
import java.util.Date;

import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Past;
import javax.validation.constraints.Size;

import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.jpa.activerecord.RooJpaActiveRecord;

@RooJavaBean
@RooJpaActiveRecord(inheritanceType = "JOINED")
public class Participante extends Usuario {

    /**
     */
    @Size(max = 50)
    private String nombre;

    /**
     */
    @Size(max = 50)
    private String apellido;

    /**
     */
    @Past
    @Temporal(TemporalType.TIMESTAMP)
    @DateTimeFormat(pattern = "dd-MM-yyyy")
    private Date fechaNac;

    /**
     */
    @NotNull
    private int dni;
    
    @Override
    public String toString() {
    	return this.getNombre() + " " + this.getApellido() + " - " + this.getEmail();
    }
    
    @Override
    public boolean equals(Object obj) {
    	if (obj instanceof Participante){
    		Participante target = (Participante) obj;
    		return this.getId() == target.getId();
    	}
    	return super.equals(obj);
    }

}
